package com.javabi.codegenerator.java.object.serializer.field.xml.type;

import com.javabi.codeobject.java.type.IJavaType;
import com.javabi.codeobject.java.type.set.IJavaTypeSet;
import com.javabi.codetype.serializer.xml.serializer.collection.ListSerializer;

public class ListSerializedType extends XmlSerializedType {

	private final XmlSerializedType component;

	public ListSerializedType(IJavaType type, XmlSerializedType component) {
		super(type);
		this.component = component;
	}

	@Override
	public void addReferences(IJavaTypeSet set) {
		set.add(getType());
		set.add(ListSerializer.class);
		component.addReferences(set);
	}

	@Override
	public String getNewSerializer(String name) {
		String element = component.getType().getSimpleName();
		return "new ListSerializer<" + element + ">(\"" + name + "\", " + component.getNewSerializer("element") + ")";
	}

}
